package io.renren.modules.quickService.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.quickService.entity.UserRightEntity;
import io.renren.modules.quickService.service.UserRightService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 用户权限
 *
 * @author zenger380
 * @email zenger380@163.com
 * @date 2018-11-22 18:03:49
 */
@RestController
@RequestMapping("quickService/userright")
public class UserRightController {
    @Autowired
    private UserRightService userRightService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("quickService:userright:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userRightService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userRightId}")
    @RequiresPermissions("quickService:userright:info")
    public R info(@PathVariable("userRightId") Long userRightId){
			UserRightEntity userRight = userRightService.selectById(userRightId);

        return R.ok().put("userRight", userRight);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("quickService:userright:save")
    public R save(@RequestBody UserRightEntity userRight){
			userRightService.insert(userRight);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("quickService:userright:update")
    public R update(@RequestBody UserRightEntity userRight){
			userRightService.updateById(userRight);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("quickService:userright:delete")
    public R delete(@RequestBody Long[] userRightIds){
			userRightService.deleteBatchIds(Arrays.asList(userRightIds));

        return R.ok();
    }

}
